$(function(){
	var userId = getUserId();
	var headerUrl = getLocalCookieHeader();
    var userName = getLocalCookieNickname();
    headerUrl = headerUrl != null && headerUrl != 'null' && headerUrl != 'undefined' && headerUrl != undefined ? headerUrl : "image/head-cion.png";
	userName = userName != null && userName != 'null' ? decodeURI(userName) : userId;
	var userInfoHtml = '<div class="userCenter-div-userImg">';
	userInfoHtml+='<img src="'+headerUrl+'" alt="" class="userInfo-img-userImg">';
	userInfoHtml+='<label for="uploadUserImg" class="userInfo-img-setting"><img src="image/userCenterSettingIcon.png" alt="" class=""></label>';
	userInfoHtml+='<input type="file" accept="image/*" capture="camera" style="display: none;" class="uploadUserImg" id="uploadUserImg">';
	userInfoHtml+='</div>';
	userInfoHtml+='<div class="userInfo-div-userName">';
	userInfoHtml+=userName;
	userInfoHtml+='</div>';
	$('.menu-div-userInfo').html(userInfoHtml);
	var centerHtml = '';
	centerHtml+='<div class="active-order menuList-div-item" id="myOrder">';
	centerHtml+='<a href="userCenterOrder.html">我的订单</a>';
	centerHtml+='</div>';
	centerHtml+='<div class="active-collection menuList-div-item" id="myCollection">';
	centerHtml+='<a href="userCenterCollection.html">我的收藏</a>';
	centerHtml+='</div>';
	centerHtml+='<div class="active-comment menuList-div-item" id="myComments">';
	centerHtml+='<a href="userCenterComments.html">我的评论</a>';
	centerHtml+='</div>';
	centerHtml+='<div class="active-setting menuList-div-item" id="mySetting">';
	centerHtml+='<a href="userCenterSetting.html">个人设置</a>';
	centerHtml+='</div>';
	centerHtml+='<div class="active-author menuList-div-item" id="myAuthor">';
	centerHtml+='<a href="userCenterAuthor.html">实名认证</a>';
	centerHtml+='</div>';
	centerHtml+='<div class="active- menuList-div-item" id="exit">';
	centerHtml+='<a href="">退出</a>';
	centerHtml+='</div>';
	$('.userInfo-div-menuList').html(centerHtml);
	$("#exit").on("click", function (e) {
    	removeLocalCookieUserId();
    	location.href = "index.html";
    });
	$(".uploadUserImg").uploadView({
		uploadBox: '.js_upFile_poster', //设置上传框容器  file
		showBox: '.imgBox', //设置显示预览图片的容器
		width: 198, //预览图片的宽度，单位px
		height: 206, //预览图片的高度，单位px
		allowType: ["gif", "jpeg", "jpg", "bmp", "png"], //允许上传图片的类型
		maxSize: 2, //允许上传图片的最大尺寸，单位M
		success: function(e) {
		    var file = document.getElementById('uploadUserImg').files[0];
		    console.log(file);
	    	var storeAs = "pic/user_headers_"+new Date().getTime()+"_"+file.name;
			multipartUpload(storeAs,file,null, null,null,function(result){
				var params = {header: storeAs};
				var ajaxParams = {headers:{userId: getLocalCookieUserId()},type: "POST",url: 'api/user/modify'};
				commonAjax(ajaxParams,params,null,function(data){
				    if(data.code == 0){
				    	layer.msg(data.msg, {icon: 1});
				    	setTimeout(function () {
				    		var localUserId = getLocalCookieUserId();
							getUserInfo(localUserId);//重新设置缓存
			            }, 2000);
						
				    }
				},null);
			});
		}
	});
});